<?php
    include('session.inc');
    require_once('funct.inc');
    include 'color_style.php';
    include LANGUAGE;
    if(!GetAdminID($AdminID)){echo LOGIN_ERR;exit;}
    

    require_once('OpenDB.inc');


    $A_Name     =$_REQUEST["A_Name"];
    $A_Surname  =$_REQUEST["A_Surname"];
    $A_Nick     =$_REQUEST["A_Nick"];
    $A_Passwd   =$_REQUEST["A_Passwd"];
    $A_Passwd2  =$_REQUEST["A_Passwd2"];



    if (!OpenDB()){echo OPEN_DB_ERR; break;}
    print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
    print "<html>";
    print "<head>";
    
    print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset="._CHARSET_.";\" />";

    include 'html_style.php';

    print "</head>";
    print "<body bgcolor=\"".Background_Color."\">";
    /*
    print $A_Nick;
    print $A_Passwd;
    print $A_Passwd2;
    print ($A_Nick!="") AND  ($A_Passwd!="") AND ($A_Passwd==$A_Passwd2);
    */

    print("<center><b>".AA_TITULOK."</b></center>");

    if (($A_Nick!="") AND  ($A_Passwd!="") AND ($A_Passwd==$A_Passwd2))
    $SQL=1;
    else
    $SQL=0;


    if ($SQL)
    {
         if(!SQL_Control_Duplicate($A_Nick,$AdminID)){
        //print "www";
        $SQL="UPDATE admins SET
                A_Name      = '".$A_Name."',
                A_Surname   = '".$A_Surname."',
                A_Nick      = '".$A_Nick."',
                A_Passwd    = '".sha1($A_Passwd)."'
              WHERE ID=".$AdminID;



        mysql_query($SQL);
	


        print "<center><h3><b>".AA_RESULT."</b></h3></center>";
        }else{
                print  "<script language=\"JavaScript\">
                <!--
                  window.alert(\"".AA_ALERT." '".$_REQUEST["A_Nick"]."'\");
                  //-->
                </script>";
                $SQL=0;
        }
    }
    if (!$SQL){
        $SQL="SELECT * FROM admins WHERE ID=".$AdminID;
        $sql_array_admin = mysql_fetch_object(mysql_query($SQL));
        print"<form action=\"adm_acount.php\" target=\"place\" method=\"post\">
                <table>
                    <tr>
                        <td> ".A_MENO.": </td>
                        <td> <input type=\"text\" name=\"A_Name\" value=\"".$sql_array_admin->A_Name."\" /> </td>
                    </tr>
                    <tr>
                        <td> ".A_PRIEZVISKO.": </td>
                        <td> <input type=\"text\" name=\"A_Surname\" value=\"".$sql_array_admin->A_Surname."\" /> </td>
                    </tr>
                    <tr>
                        <td> ".A_NICK.": </td>
                        <td> <input type=\"text\" name=\"A_Nick\" value=\"".$sql_array_admin->A_Nick."\" /> </td>
                    </tr>
                    <tr>
                        <td> ".A_HESLO.": </td>
                        <td> <input type=\"password\" name=\"A_Passwd\" value=\"\" /> </td>
                    </tr>
                    <tr>
                        <td> ".A_HESLO_OPAKUJ.": </td>
                        <td> <input type=\"password\" name=\"A_Passwd2\" value=\"\" /> </td>
                    </tr>
                    <tr>
                        <td colspan=2>
                        <input type=\"submit\" value=\"".A_ULOZIT."\" style=\"width :300px; background-color: ".BUTTON_ON_OUT.";\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
                        </td>
                    </tr>
            </form>";
    }


    print "</body>";
    mysql_close();
print "</html>";
?>
